package com.hugedata.cdn.service.task.impl;

import java.sql.Timestamp;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.transaction.TransactionStatus;

import com.hugedata.cdn.base.services.BaseServiceImpl;
import com.hugedata.cdn.service.task.bean.AlarmBean;
import com.hugedata.cdn.service.task.bean.AlarmUserBean;
import com.hugedata.cdn.service.task.bean.NodeBean;
import com.hugedata.cdn.service.task.bean.RunningTaskBean;
import com.hugedata.cdn.service.task.bean.TaskBean;
import com.hugedata.cdn.service.task.bean.TaskInfoSupplementBean;
import com.hugedata.cdn.service.task.bean.TaskIspLocBean;
import com.hugedata.cdn.service.task.bean.TaskResultBean;
import com.hugedata.cdn.service.task.bean.TaskSessionBean;
import com.hugedata.cdn.service.task.bean.report.ResultTask;
import com.hugedata.cdn.util.CdnException;
import com.hugedata.cdn.util.CdnTransactionCallback;
import com.hugedata.cdn.util.CdnTransactionTemplate;
import com.hugedata.cdn.util.CommonUtil;
import com.hugedata.cdn.util.ResultCode;

/**
 * 项目名称：xiaomifeng 类名称：TaskService 类描述： 创建人：zhaoaihua 创建时间�?013-3-19 下午6:14:09
 * 修改备注�?
 * 
 * @version
 */
public class TaskService extends BaseServiceImpl
{

    /** 事务模版工具�? */
    private CdnTransactionTemplate cdnTransactionTemplate;

    private CommonUtil commonutil;

    @Override
    protected String getDomainName()
    {
        return "taskSql";
    }

    /**
     * modTaskDbResult 维护节点任务结果表 back_child_task_info
     * 
     * @param TaskClientReport
     *            XmfException 异常对象
     */
    public boolean modTaskDbResult(final String clientId,
            final ResultTask reporttaskbean) throws CdnException
    {
        try
        {
            // final RunningTaskBean task = getNodeTaskResult(clientId,
            // reporttaskbean);
            this.cdnTransactionTemplate.execute(new CdnTransactionCallback()
            {
                @Override
                public void doInTransactionNoResult(TransactionStatus status)
                        throws CdnException
                {
                    // if (null == task)
                    // {
                    // // addNodeTaskResult(reporttaskbean);
                    // throw new CdnException(ResultCode.reportDataError,
                    // "no this task is error, taskId ="
                    // + reporttaskbean.getTaskID());
                    // }
                    // else
                    // {
                    //
                    // int tempresult = Integer.parseInt(task.getResultFlag(),
                    // 2);
                    // task.setResultFlag(commonutil.StringFormat(
                    // Integer.toBinaryString((tempresult << 1)
                    // | reporttaskbean.getFault()), 16));
                    // try
                    // {
                    // Gson gson = new Gson();
                    // task.setReportSnapshot(gson.toJson(reporttaskbean));
                    // String monitoringTime = reporttaskbean.getData()[0]
                    // .getMonitoringTime();
                    // SimpleDateFormat simpleDateFormat = new SimpleDateFormat(
                    // "yyyyMMddHHmmss");
                    // Timestamp timestamp = new Timestamp(
                    // simpleDateFormat.parse(monitoringTime)
                    // .getTime());
                    // task.setLastTimestamp(timestamp);
                    // }
                    // catch (Exception e1)
                    // {
                    // throw new CdnException(ResultCode.reportTimeError,
                    // "parse MonitoringTime error", e1);
                    // }
                    // // back_child_task_info
                    // updateNodeTaskResult(task);
                    // }

                    TaskResultBean resultbean = getTaskResult(reporttaskbean
                            .getTaskID());

                    try
                    {

                        resultbean.setLast_timestamp(new Timestamp(
                                new SimpleDateFormat("yyyyMMddHHmmss").parse(
                                        reporttaskbean.getData()[0]
                                                .getMonitoringTime()).getTime()));
                    }
                    catch (ParseException e1)
                    {
                        log.error("parse date exception", e1);
                        throw new CdnException(ResultCode.reportTimeError,
                                "parse MonitoringTime error", e1);
                    }

                    if (resultbean.getStatus() == 2)
                    {
                        resultbean.setStatus(0);

                        recoverTaskResult(resultbean);
                    }
                    else
                    {
                        updateTaskResultReport(resultbean);
                    }
                }
            });
        }
        catch (CdnException e)
        {

            log.error("db operator error , errorcode = " + e.getErrorNum(), e);

            throw e;

        }

        return true;
    }

    /**
     * updateTaskResult 更新TaskResultBean
     * 
     * @param TaskResultBean
     * @throws XmfException
     * @Exception 异常对象
     */
    public void updateTaskResultReport(TaskResultBean bean) throws CdnException
    {

        this.update("updateTaskResultReport", bean);

    }

    /**
     * recoverTaskResult 更新TaskResultBean
     * 
     * @param TaskResultBean
     * @throws XmfException
     * @Exception 异常对象
     */
    public void recoverTaskResult(TaskResultBean bean) throws CdnException
    {

        this.update("recoverTaskResult", bean);

    }

    /**
     * getTaskResult 获取一条任务结果bean
     * 
     * @return TaskResultBean
     * @throws XmfException
     */
    public TaskResultBean getTaskResult(String taskID) throws CdnException
    {

        return (TaskResultBean) this.queryForObject("getTaskResult", taskID);

    }

    /**
     * modTaskUpdateFlag 更新已修改任务的标记位
     * 
     * @param RunningTaskBean
     * @throws XmfException
     * @Exception 异常对象
     * @since CodingExample　Ver(编码范例查看) 1.1
     */
    public void updateNodeTaskResult(RunningTaskBean bean) throws CdnException
    {

        this.update("updateNodeTaskResult", bean);

    }

    /**
     * getTaskResult 获取一条任务bean
     * 
     * @return RunningTaskBean
     * @throws XmfException
     */
    public RunningTaskBean getNodeTaskResult(final String clientId,
            final ResultTask reporttaskbean) throws CdnException
    {

        Map<String, String> map = new HashMap<String, String>();
        map.put("nodeID", clientId);
        map.put("taskID", reporttaskbean.getTaskID());

        return (RunningTaskBean) this.queryForObject("getNodeTaskResult", map);

    }

    /**
     * repairTaskRelation 发�?任务后，修护任务关系�?
     * 
     * @param addtask
     * @param modtask
     * @param deltask
     * @return boolean
     * @Exception 异常对象
     */
    public boolean repairTaskRelation(final List<TaskBean> addtask,
            final List<TaskBean> modtask, final List<String> deltask,
            final NodeBean bean, final int taskMode) throws CdnException
    {
        try
        {
            this.cdnTransactionTemplate.execute(new CdnTransactionCallback()
            {
                @Override
                public void doInTransactionNoResult(TransactionStatus status)
                        throws CdnException
                {

                    // 更新节点为可�?
                    // updateNodeStatus(bean, 0);

                    // 更新节点任务�?
                    updateNodeTaskNums(bean);

                    if (taskMode == 1 || taskMode == 0)
                    {
                        for (TaskBean temp : addtask)
                        {
                            // 新增的任务维护到back_child_task_info
                            addNodeRunningTask(bean.getNodeID(),
                                    temp.getTaskID());
                            // init task to task_result_info
                            initTaskResult(temp);

                            commonutil.addTaskBean(temp);
                            commonutil.addTNmap(temp.getTaskID(),
                                    countNodesByTaskid(temp.getTaskID()));
                        }
                    }

                    for (TaskBean temp : modtask)
                    {
                        // 更新被修改的task的标�?
                        modTaskUpdateFlag(temp);

                        commonutil.modTaskBean(temp);
                        commonutil.modTNMap(temp.getTaskID(),
                                countNodesByTaskid(temp.getTaskID()));
                    }

                    for (String taskid : deltask)
                    {
                        // 删除运行的子任务
                        delNodeRunningTask(bean.getNodeID(), taskid);

                        commonutil.delTaskBean(taskid);
                        commonutil.delTNMap(taskid);
                    }

                    // test transaction
                    // addNodeRunningTask("17", "11");
                    // addNodeRunningTask("14", null);

                }
            });
        }
        catch (CdnException e)
        {

            log.error("db operator error , errorcode = " + e.getErrorNum());

            throw e;

        }

        return true;
    }

    /**
     * findchildTasksByTaskid 获取任务的子任务
     * 
     * @param taskID
     * @param @return 设定文件
     * @return List<RunningTaskBean> RunningTaskBean列表
     * @throws CdnException
     * @Exception 异常对象
     * @since CodingExample�?er(编码范例查看) 1.1
     */
    @SuppressWarnings("unchecked")
    public List<RunningTaskBean> findchildTasksByTaskid(String taskID)
            throws CdnException
    {

        return (List<RunningTaskBean>) this.queryForList(
                "findchildTasksByTaskid", taskID);
    }

    /**
     * getAddTaskinfoById 过滤出此刻该节点新增的任�?
     * 
     * @param NodeBean
     * @param List
     *            <TaskBean>
     * @return List<TaskBean>
     * @Exception 异常对象
     * @since CodingExample�?er(编码范例查看) 1.1
     */
    public List<TaskBean> getAddTaskinfoById(List<RunningTaskBean> runBeans,
            List<TaskBean> effectBeans)
    {

        List<TaskBean> addtasks = new ArrayList<TaskBean>();

        if (runBeans.size() > 0)
        {
            for (TaskBean temp : effectBeans)
            {

                if (!isPartof(temp, runBeans))
                {
                    addtasks.add(temp);
                }
            }
        }
        else
        {
            return effectBeans;
        }

        return addtasks;

    }

    /**
     * getmodTaskinfoById 过滤出此刻该节点修改的任�?
     * 
     * @param NodeBean
     * @param List
     *            <TaskBean>
     * @return List<TaskBean>
     * @throws CdnException
     * @Exception 异常对象
     * @since CodingExample�?er(编码范例查看) 1.1
     */
    public List<TaskBean> getmodTaskinfoById(NodeBean bean,
            List<TaskBean> effectBeans) throws CdnException
    {

        List<TaskBean> modtasks = new ArrayList<TaskBean>();

        if (null == bean)
        {
            return modtasks;
        }

        List<TaskBean> beanmods = findTasksModQualityByNode(bean);

        if (beanmods.size() > 0)
        {
            for (TaskBean temp : effectBeans)
            {

                if (isPortofAndMod(temp, beanmods))
                {
                    modtasks.add(temp);
                }
            }
        }

        return modtasks;

    }

    /**
     * getdelTaskinfoById 过滤出此刻该节点删除或暂停的任务
     * 
     * @param NodeBean
     * @param List
     *            <TaskBean>
     * @return List<TaskBean>
     * @throws CdnException
     * @Exception 异常对象
     * @since CodingExample�?er(编码范例查看) 1.1
     */
    public List<String> getdelTaskinfoById(NodeBean bean,
            List<RunningTaskBean> runBeans) throws CdnException
    {

        List<String> deltasks = new ArrayList<String>();

        if (null == bean)
        {
            return deltasks;
        }

        List<TaskBean> unknowsbeans = findUnEffectiveTasksByNode(bean);

        if (unknowsbeans.size() > 0)
        {
            for (RunningTaskBean temp : runBeans)
            {

                if (isPortof(temp, unknowsbeans))
                {
                    deltasks.add(temp.getTaskID());
                }
            }
        }

        return deltasks;

    }

    /**
     * getdelTaskinfoById 过滤出此刻该节点删除或暂停的任务
     * 
     * @param (List<RunningTaskBean>
     * @param List
     *            <TaskBean>
     * @return List<String>
     * @throws CdnException
     * @Exception 异常对象
     * @since CodingExample�?er(编码范例查看) 1.1
     */
    public List<String> getdelTaskinfoById(List<RunningTaskBean> runBeans,
            List<TaskBean> effectBeans) throws CdnException
    {

        List<String> deltasks = new ArrayList<String>();

        if (effectBeans.size() > 0)
        {
            for (RunningTaskBean temp : runBeans)
            {

                if (!isPartof(temp, effectBeans))
                {
                    deltasks.add(temp.getTaskID());
                }
            }
        }
        else
        {
            for (RunningTaskBean temp : runBeans)
            {
                deltasks.add(temp.getTaskID());
            }
        }

        return deltasks;

    }

    /**
     * findNodeinfoByNodeID 获取一个节点详情
     * 
     * @param nodeID
     * @param @return 设定文件
     * @return NodeBean
     * @throws XmfException
     * @Exception 异常对象
     */
    public NodeBean findNodeinfoByNodeID(String nodeID) throws CdnException
    {

        return (NodeBean) this.queryForObject("findNodeinfoById", nodeID);
    }

    /**
     * findTaskinfoByID 获取�?��task详情
     * 
     * @param taskID
     * @param @return 设定文件
     * @return TaskBean
     * @throws CdnException
     * @Exception 异常对象
     */
    public TaskBean findTaskinfoByID(String taskID) throws CdnException
    {

        // return (TaskBean) this.queryForObject("findTaskByid", taskID);
        // TASK-REPLE
        return (TaskBean) this.queryForObject("getTaskBeanByid", taskID);
    }
    
    public List<TaskBean> queryAllTaskInfo()
    {
        return (List<TaskBean>)super.getSqlMapClientTemplate().queryForList("queryAllTaskInfo");
    }
    
    public TaskInfoSupplementBean findTaskInfoSupplement(String taskID)
    {
        return (TaskInfoSupplementBean) this.getSqlMapClientTemplate().queryForObject("findTaskInfoSupplement", taskID);
    }
    
    /**
     * 
    * @Title: decreaseSmsNum
    * @Description: 递减当前用户可用短信条数
    * @author wangxiaoming
    * @param bean
    * @return
    * @throws
     */
    public int decreaseSmsNum(TaskInfoSupplementBean bean)
    {
        return this.getSqlMapClientTemplate().update("updateSmsNum", bean);
    }
    
    /**
     * 
    * @Title: countSmsNum
    * @Description: 查看可用短信条数
    * @author wangxiaoming
    * @param bean
    * @return
    * @throws
     */
    public int countSmsNum(TaskInfoSupplementBean bean)
    {
        return (Integer) super.getSqlMapClientTemplate().queryForObject("countSmsNum", bean);
    }

    /**
     * findTasks 获取�?��任务�?
     * 
     * @return List<TaskBean> TaskBean列表
     * @throws CdnException
     * @Exception 异常对象
     */
    @SuppressWarnings("unchecked")
    public List<TaskBean> findTasks() throws CdnException
    {

        // return (List<TaskBean>) this.queryForList("findTasks");
        return (List<TaskBean>) this.queryForList("findTasksjoin");

    }

    // add by luxiumin 201403010 -开始
    @SuppressWarnings("unchecked")
    public List<TaskBean> findTasksIdList() throws CdnException
    {
        return (List<TaskBean>) this.queryForList("findTasksIdList");
    }

    // wangz 查询ISPLOC
    @SuppressWarnings("unchecked")
    public List<TaskIspLocBean> findisplocList(String taskid)
            throws CdnException
    {
        return (List<TaskIspLocBean>) this.queryForList("findIspLocList",
                taskid);
    }

    /**
     * findNodes 获取�?��节点信息
     * 
     * @return List<NodeBean> NodeBean列表
     * @throws CdnException
     * @Exception 异常对象
     */
    @SuppressWarnings("unchecked")
    public List<NodeBean> findNodes() throws CdnException
    {

        return (List<NodeBean>) this.queryForList("findNodes");
    }

    /**
     * findNodeNameByID 获取节点名称
     * 
     * @return String
     * @throws CdnException
     * @Exception 异常对象
     */

    public String findNodeNameByID(String nodeID) throws CdnException
    {

        return (String) this.queryForObject("findNodeNameByID", nodeID);
    }

    /**
     * findNodeNameByID 获取节点名称
     * 
     * @return String
     * @throws CdnException
     * @Exception 异常对象
     */

    public String findNodeCodeByNodeID(String nodeID) throws CdnException
    {

        return (String) this.queryForObject("findNodeCodeByNodeID", nodeID);
    }

    /**
     * findNodeNameByID 获取节点当前运行的任务数，满载的情况
     * 
     * @return String
     * @throws CdnException
     * @Exception 异常对象
     */

    public String findtaskrunnumsByID(String nodeID) throws CdnException
    {

        return (String) this.queryForObject("findtaskrunnumsByID", nodeID);
    }

    /**
     * findEffectiveTasksByNode 获取�?��节点有效的任务数
     * 
     * @param NodeBean
     * @param @return 设定文件
     * @return List<TaskBean> TaskBean列表
     * @throws CdnException
     * @Exception 异常对象
     */
    @SuppressWarnings("unchecked")
    public List<TaskBean> findEffectiveTasksByNode(NodeBean bean)
            throws CdnException
    {

        // return (List<TaskBean>) this.queryForList("findEffectiveTasksByNode",
        // bean);

        return (List<TaskBean>) this.queryForList(
                "findEffectiveTasksjoinByNode", bean);

    }

    /**
     * findUnEffectiveTasksByNode 获取�?��节点无效的任务数�?该任务可能被用户暂停或删�?
     * 
     * @param NodeBean
     * @param @return 设定文件
     * @return List<TaskBean> TaskBean列表
     * @throws CdnException
     * @Exception 异常对象
     * @since CodingExample�?er(编码范例查看) 1.1
     */
    @SuppressWarnings("unchecked")
    public List<TaskBean> findUnEffectiveTasksByNode(NodeBean bean)
            throws CdnException
    {

        return (List<TaskBean>) this.queryForList("findUNEffectiveTasksByNode",
                bean);
    }

    /**
     * findRunningTasksByNode 获取已同步到客户端的任务列表
     * 
     * @param NodeBean
     * @param @return 设定文件
     * @return List<RunningTaskBean> RunningTaskBean列表
     * @throws CdnException
     * @Exception 异常对象
     * @since CodingExample�?er(编码范例查看) 1.1
     */
    @SuppressWarnings("unchecked")
    public List<RunningTaskBean> findRunningTasksByNode(NodeBean bean)
            throws CdnException
    {

        return (List<RunningTaskBean>) this.queryForList(
                "findRunningTasksByNode", bean);
    }

    /**
     * findTasksModQualityByNode 获取已同步到客户端的任务列表的修改标�?
     * 
     * @param NodeBean
     * @param @return 设定文件
     * @return List<RunningTaskBean> RunningTaskBean列表
     * @throws CdnException
     * @Exception 异常对象
     * @since CodingExample�?er(编码范例查看) 1.1
     */
    @SuppressWarnings("unchecked")
    public List<TaskBean> findTasksModQualityByNode(NodeBean bean)
            throws CdnException
    {

        return (List<TaskBean>) this.queryForList("findTasksModQualityByNode",
                bean);
    }

    /**
     * addNodeRunningTask 维护动�?任务表，为节点增加一条实时任�?
     * 
     * @param nodeID
     * @param taskID
     * @throws CdnException
     * @Exception 异常对象
     * @since CodingExample�?er(编码范例查看) 1.1
     */
    public void addNodeRunningTask(String nodeID, String taskID)
            throws CdnException
    {

        Map<String, String> map = new HashMap<String, String>();
        map.put("nodeID", nodeID);
        map.put("taskID", taskID);

        this.insert("insertChildTask", map);
    }

    /**
     * addNodeRunningTask 维护动�?任务表，为节点增加一条实时任�?
     * 
     * @param nodeID
     * @param taskID
     * @throws CdnException
     * @Exception 异常对象
     * @since CodingExample�?er(编码范例查看) 1.1
     */
    public void delNodeRunningTask(String nodeID, String taskID)
            throws CdnException
    {

        Map<String, String> map = new HashMap<String, String>();
        map.put("nodeID", nodeID);
        map.put("taskID", taskID);

        this.delete("deleteChildTask", map);
    }

    /**
     * addNodeRunningTask 维护动�?任务表，为节点增加一条实时任�?
     * 
     * @param TaskBean
     * @throws CdnException
     * @Exception 异常对象
     * @since CodingExample�?er(编码范例查看) 1.1
     */
    public void initTaskResult(TaskBean bean) throws CdnException
    {

        this.insert("initTaskResult", bean);
    }

    /**
     * modTaskUpdateFlag 更新已修改任务的标记�?
     * 
     * @param TaskBean
     * @throws CdnException
     * @Exception 异常对象
     * @since CodingExample�?er(编码范例查看) 1.1
     */
    public void modTaskUpdateFlag(TaskBean bean) throws CdnException
    {

        this.update("updateTaskUpdateFlag", bean);

    }

    /**
     * updateNodeStatus 更新节点机器的busy状�?
     * 
     * @param NodeBean
     * @param int
     * @throws CdnException
     * @Exception 异常对象
     * @since CodingExample�?er(编码范例查看) 1.1
     */
    public void updateNodeStatus(NodeBean bean, int status) throws CdnException
    {

        bean.setStatus(status);
        this.update("updateNodeStatus", bean);

    }

    /**
     * updateNodeTaskNums 更新节点机器的任务数
     * 
     * @param NodeBean
     * @param int
     * @throws CdnException
     * @Exception 异常对象
     * @since CodingExample�?er(编码范例查看) 1.1
     */
    public void updateNodeTaskNums(NodeBean bean) throws CdnException
    {

        this.update("updateNodeTaskNums", bean);

    }

    /**
     * 获取code获取节点信息
     * 
     * @return List<NodeBean> NodeBean列表
     * @throws CdnException
     * @Exception 异常对象
     */
    @SuppressWarnings("unchecked")
    public List<NodeBean> getNodesbyCode(String Nodecode) throws CdnException
    {

        return (List<NodeBean>) this.queryForList("getNodesbyCode", Nodecode);
    }

    /**
     * 获取code获取节点信息
     * 
     * @return List<NodeBean> NodeBean列表
     * @throws CdnException
     * @Exception 异常对象
     */
    @SuppressWarnings("unchecked")
    public List<String> getNodesBasis() throws CdnException
    {

        return (List<String>) this.queryForList("getNodesBasis");
    }

    /**
     * countNodesByTaskid 统计某个任务的探测节点数
     * 
     * @param String
     *            taskid
     * @return 探测节点�?
     * @throws CdnException
     */
    public int countNodesByTaskid(String taskId) throws CdnException
    {
        return (Integer) this.queryForObject("countNodesByTaskid", taskId);
    }

    private boolean isPartof(TaskBean bean, List<RunningTaskBean> beans)
    {
        if (null == bean)
        {
            return true;
        }

        for (RunningTaskBean temp : beans)
        {
            if (temp.getTaskID().equalsIgnoreCase(bean.getTaskID()))
            {
                return true;
            }
        }

        return false;
    }

    private boolean isPartof(RunningTaskBean bean, List<TaskBean> beans)
    {
        if (null == bean)
        {
            return true;
        }

        for (TaskBean temp : beans)
        {
            if (temp.getTaskID().equalsIgnoreCase(bean.getTaskID()))
            {
                return true;
            }
        }

        return false;
    }

    private boolean isPortofAndMod(TaskBean bean, List<TaskBean> beanmods)
    {
        if (null == bean)
        {
            return false;
        }

        for (TaskBean temp : beanmods)
        {
            if (temp.getTaskID().equalsIgnoreCase(bean.getTaskID()))
            {

                if (temp.getUpdateFalg() != bean.getUpdateFalg())
                    return true;
            }
        }

        return false;
    }

    private boolean isPortof(RunningTaskBean bean, List<TaskBean> beans)
    {
        if (null == bean)
        {
            return false;
        }

        for (TaskBean temp : beans)
        {
            if (temp.getTaskID().equalsIgnoreCase(bean.getTaskID()))
            {
                return true;
            }
        }

        return false;
    }

    // public ExecutorService getExecuter()
    // {
    // return commonutil.reportTaskPool();
    // }

    public void setCdnTransactionTemplate(
            CdnTransactionTemplate cdnTransactionTemplate)
    {
        this.cdnTransactionTemplate = cdnTransactionTemplate;
    }

    public void setCommonutil(CommonUtil commonutil)
    {
        this.commonutil = commonutil;
    }

    /* 日志系统添加，PD返回sessionid需要入库 */

    public void insertTaskSessionId(TaskSessionBean bean) throws CdnException
    {

        this.insert("insertTaskSessionId", bean);
    }

    /**
     * 
    * @Title: queryTasks
    * @Description: 查询告警设置
    * @author wangxiaoming
    * @return
    * @throws
     */
    public List<AlarmBean> queryTaskAlarms()
    {
        return (List<AlarmBean>)this.getSqlMapClientTemplate().queryForList("queryTaskAlarms");
    }
    
    /**
     * 
    * @Title: updateWarnFlag
    * @Description: 更新报警标记位
    * @author wangxiaoming
    * @param alarmBean
    * @throws
     */
    public void updateWarnFlag(AlarmBean alarmBean)
    {
        super.getSqlMapClientTemplate().update("updateWarnFlag", alarmBean);
    }
    
    /**
     * 
    * @Title: queryTaskAlarmUsers
    * @Description: 查询被告警的用户
    * @author wangxiaoming
    * @return
    * @throws
     */
    public List<AlarmUserBean> queryTaskAlarmUsers(AlarmBean bean)
    {
        return (List<AlarmUserBean>)this.getSqlMapClientTemplate().queryForList("queryTaskAlarmUsers", bean);
    }
    
    /**
     * 
    * @Title: queryUrlBySiteid
    * @Description: 根据siteid对应的url
    * @author wangxiaoming
    * @param bean
    * @return
    * @throws
     */
    public String queryUrlBySiteid(AlarmBean bean)
    {
        return (String) this.getSqlMapClientTemplate().queryForObject("queryUrlBySiteid", bean);
    }
}
